"use strict";

//var sequelize = require('../sequelize.js');
var sequelize = require('../sequelize.js');
var Sequelize = require('sequelize');
let DataTypes = Sequelize;

var Order = sequelize.define('mh_order', {
    //订单号
    orderid: {
      type: DataTypes.INTEGER(10),
      primaryKey: true,
      autoIncrement: true,
      allowNull: false
    },
    //订单编号
    order_code: {
      type: DataTypes.STRING(),
      allowNull: true
    },
    //商家、供应商
    vendorid: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: '1'
    },
    //商品id
    wareid: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: '0'
    },
    //商品版本
    warever: {
      type: DataTypes.INTEGER(4),
      allowNull: true
    },
    //用户id
    uid: {
      type: DataTypes.INTEGER(10),
      allowNull: false
    },
    actid: {
      type: DataTypes.INTEGER(11),
      allowNull: true,
      defaultValue: '0'
    },
    //价格
    price: {
      type: DataTypes.DECIMAL(10, 2),
      allowNull: true,
      defaultValue: '0.00'
    },
    //总价
    total_price: {
      type: DataTypes.DECIMAL(10, 2),
      allowNull: true,
      defaultValue: '0.00'
    },
    //数量
    quantity: {
      type: DataTypes.INTEGER(3),
      allowNull: true,
      defaultValue: '1'
    },
    //下单时间
    date: {
      type: DataTypes.INTEGER(10),
      allowNull: true
    },
    //货运方式 1 凭短信领取, 2 邮寄
    shiptype: {
      type: DataTypes.INTEGER(2),
      allowNull: true,
      defaultValue: '0'
    },
    //是否领取 0未领取,1领取
    receive: {
      type: DataTypes.INTEGER(2),
      allowNull: true,
      defaultValue: '0'
    },
    //付款方式  1:到店支付；2在线支付
    pay_way: {
      type: DataTypes.INTEGER(1),
      allowNull: true,
      defaultValue: '1'
    },
    //付款日期
    pay_date: {
      type: DataTypes.INTEGER(10),
      allowNull: true
    },

    //已消费数量
    has_consumed_number: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //退款中数量
    refunding_number: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //已退款数量
    has_refunded_number: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //退款时间
    refund_date: {
      type: DataTypes.INTEGER(10),
      allowNull: true
    },

    //消费日期
    consume_date: {
      type: DataTypes.INTEGER(10),
      allowNull: true
    },
    //对应美容日记贴id 0 没发美容日记帖 非0 返回美容日记贴id  默认0
    daily_thread_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //消费状态 0不在状态范围 1未消费 2已消费
    consumption_status: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //退款状态 0 没退款 1 有退款
    refund_status: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //支付状态 0 未付款 1已付款
    payment_status: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //评价状态 0 不在状态范围 1 未评价 1已评价
    evaluation_status: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //订单状态: 0 不可用 1可用
    status: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      defaultValue: 0
    },
    //备注
    remarks: {
      type: DataTypes.STRING(),
      allowNull: true
    }

  },
  {
    indexes: [
      {
        unique: true,
        fields: ['orderid']
      }
    ],
    tableName: 'mh_order',
    createdAt: false,
    updatedAt: false
  }
);

module.exports = Order;